package com.xlh.listener;

import cn.hutool.core.io.FileUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 异步任务
 * <p>
 * Created by lx on 2018/6/22.
 */
@Component
public class AsyncTask {

    /**
     * 异步删除资源
     *
     * @param deleteData 删除的数据
     */
    @Async("taskExecutor")
    public void asyncDeleteStaticResources(List<String> deleteData) {
        if (CollectionUtils.isEmpty(deleteData)) return;
        deleteData.forEach(path -> {
            FileUtil.del(path);
        });
    }

}
